package kla;

import static org.junit.Assert.assertEquals;
import robocode.control.testing.RobotTestBed;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;

/**
 * This test verifies that Tankadin always beats Target. 
 * 
 * @author Ardell Klemme
 */
public class TestTankadinVersusTarget extends RobotTestBed {

  /**
   * Specifies that Target and Tankadin are to be matched up in this test case.
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.Target,kla.Tankadin";
  }
  
  /**
   * This test runs for 10 rounds.
   * @return The number of rounds. 
   */
  @Override
  public int getNumRounds() {
    return 10;
  }
  
  /**
   * Test asserts that Tankadin will win against Target always.
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    BattleResults[] battleResults = event.getIndexedResults();
    BattleResults TankadinResults = battleResults[1];
    String robotName = TankadinResults.getTeamLeaderName();
    assertEquals("Check that results[1] is Tankadin", robotName, "kla.Tankadin*");
    
    // Check to make sure Tankadin wins every round.
    assertEquals("Check Tankadin winner", getNumRounds(), TankadinResults.getFirsts());
  }
}